import Vue from 'vue'
import Vuex from 'vuex'
import api from '@/api/index.js'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    code:"",
    access_token:"",
    openid: "obD_t1CJQMV3LhLx0psum-iUdudI", // obD_t1DQGbgVrCFnluGvhS12uhR8
    appid: "",
    secret: "",
    masterColor: "#FF0000",
    isLogin: false,
    tabbar: [],
    swipeList: [],
    caseTabsList: [],
    caseList: [],
    caseListFinished: false,
    caseItem: "",
    activityItem: "",
    userInfo:'',
    activityData:{},
    activityStatus1:'',
    fansInfo:'',
    myInfo:'',
    minimum:'',
    //game
    passInfo: [],
    isPass: false,
    fivepass: ['game2','game4', 'game6','game10','game14'],
    addressList: [{
      value: 1,
      text: '世茂江海天成',
      address: '南通通州湾江海联动开发示范区百进路与金海路交汇处',
      award:'弹跳杯',

    },{
      value: 2,
      text: '世茂璀璨未来',
      address: '南通崇川区长泰路与永达路交汇处向东100米',
      award: '杂粮礼盒'
    },{
      value: 3,
      text: '世茂璀璨星河',
      address: '江苏省盐城市城南新区学海路与康居路交汇处向东150米世茂璀璨星河营销中心',
      award: '恒温杯'
    },{
      value: 4,
      text: '常熟世茂世纪中心',
      address: '常熟市闽江东路11号世茂世纪中心B幢售楼处（星光天地西侧）',
      award: '定制明信片'
    },{
      value: 5,
      text: '观溪和园',
      address: '常熟市辛庄镇繁荣路28号观溪和园营销中心',
      award: '精美笔记本套装'
    },{
      value: 6,
      text: '云湖漫城',
      address: '上海市嘉定区惠亚路与嘉美路交叉口，云湖漫城售楼处',
      award: '精致香薰'
    },{
      value: 7,
      text: '镇江世茂云图花园',
      address: '镇江市润州区三里岗路与宝平路交叉口往西南约150米',
      award: '珊瑚毯'
    },{
      value: 8,
      text: '常熟世茂璀璨澜庭',
      address: '常熟市深圳路与常福路交汇处往南约100米',
      award: '日式便当盒'
    },{
      value: 9,
      text: '张家港永安路项目',
      address: '张家港市世茂和光荟售楼处',
      award: '风扇台灯'
    }]
  },
  mutations: {
    setFivepass(state,rawData){
	    state.fivepass = rawData;
	  },
    setIsPass(state,rawData){
	    state.isPass = rawData;
	  },
    setMininum(state,rawData){
	    state.minimum = rawData;
	  },
    setMyInfo(state,rawData){
	    state.myInfo = rawData;
	  },
    setActivityStatus1(state,rawData){
	    state.activityStatus1 = rawData;
	  },
    setActivityData(state,rawData){
	    state.activityData = rawData;
	  },
    setUserInfo(state,rawData){
	    state.userInfo = rawData;
	  },
    setAccessToken(state,rawData){
	    state.access_token = rawData;
	  },
    setOpenid(state,rawData){
	    state.openid = rawData;
	  },
    setCode(state,rawData){
	    state.code = rawData;
	  },
    setActivityItem(state,rawData){
	    state.activityItem = rawData;
	  },
    setCaseTabsList(state,rawData){
	    state.caseTabsList = rawData;
	  },
    setCaseList(state,rawData){
	    state.caseList = rawData;
	  },
    setCaseListFinished(state, b){
	    state.caseListFinished = b;
	  },
    setCaseItem(state,rawData){
	    state.caseItem = rawData;
	  },
    setSwipeList(state,rawData){
	    state.swipeList = rawData;
	  },
    setAppid(state,rawData){
	    state.appid = rawData;
	  },
    setSecret(state,rawData){
	    state.secret = rawData;
	  },
    setTabbar(state,rawData){
	    state.tabbar = rawData;
	  },
    setColor(state,rawData){
	    state.mainColor = rawData;
      console.log(state.mainColor)
	  },
    setMasterColor(state,rawData){
	    state.masterColor = rawData;
      console.log(state.masterColor)
	  },
  },
  actions: {
    async getCaseList(context,params = {type_id: 0,pageNo: 1,pageSize: 10}){
      await api.getCaseList(params).then(res=>{
        context.commit('setCaseList', res.data);
        return res.data;
      })
    },
  },
  getters: {
    getOpenid(state) {
      return state.openid;
    },
    getAppid(state) {
      return state.appid;
    },
    getSecret(state) {
      return state.secret;
    },
    getMasterColor(state) {
      return state.masterColor;
    },
    getMainColor(state) {
      return state.masterColor;
    },
    getTabbar(state) {
      return state.tabbar;
    },
    getSwipeList(state) {
      return state.swipeList;
    },
    getCaseTabsList(state) {
      return state.caseTabsList;
    },
    getCaseList(state) {
      return state.caseList;
    },
    getCaseListFinished(state) {
      return state.caseListFinished;
    },
    getCaseItem(state) {
      return state.caseItem;
    }
  },
  modules: {
  }
})
